package com.alibaba.dubbo.dynamic.util;

import com.alibaba.dubbo.common.utils.IOUtils;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by wuyu on 2016/8/10.
 */
public class UrlConnectionUtil {

    public void download(String urlPath, String outPath) throws IOException {
        URL url = new URL(urlPath);
        URLConnection urlConnection = url.openConnection();
        InputStream inputStream = urlConnection.getInputStream();
        FileOutputStream fileOutputStream = new FileOutputStream(outPath);
        IOUtils.write(inputStream, fileOutputStream);
        fileOutputStream.close();
        inputStream.close();
    }
}
